package com.maoslv.dto;

import java.io.Serializable;

public class Result implements Serializable {
    private Integer code; //200正常，非200异常
    private String message;
    private Object data;

    public Result() {
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code='" + code + '\'' +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    //定义成功后 返回的结果
    public static Result succ(String message, Object data) {
        return new Result(200,message,data);
    }

    //定义失败后 返回的结果
    public static Result fail(Integer code, String message) {
        return new Result(code,message);
    }

    public static Result fail(String message) {
        return new Result(500,message);
    }
}
